﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace iNet.Media.Xmp.MicrosoftPhoto
{
	public class RegionXmpPropertyValue : StructureXmpPropertyValue
	{
		#region 欄位
		public static readonly XmpSchema DefaultSchema = new XmpSchema("MPReg", "http://ns.microsoft.com/photo/1.2/t/Region#");
		#endregion
		#region 建構子
		public RegionXmpPropertyValue()
			: this(DefaultSchema)
		{ }
		public RegionXmpPropertyValue(XmpSchema schema)
			: base(schema)
		{
			if (schema == null)
				throw new ArgumentNullException("schema");
		}
		#endregion
		#region CloneCore
		protected override XmpPropertyValue CloneCore()
		{
			RegionXmpPropertyValue value = new RegionXmpPropertyValue(this.Schema);
			this.CopyFieldsTo(value);
			return value;
		}
		#endregion
		#region FieldNames
		public override string[] FieldNames
		{
			get 
			{
				return new string[]
				{
					"PersonDisplayName",
					"PersonEmailDigest",
					"PersonLiveCID",
					"Rectangle"
				};
			}
		}
		#endregion
		#region GetFieldCore
		protected override XmpPropertyValue GetFieldCore(string name)
		{
			switch (name)
			{
				case "PersonDisplayName":
					return this.PersonDisplayName;
				case "PersonEmailDigest":
					return this.PersonEmailDigest;
				case "PersonLiveCID":
					return this.PersonLiveCID;
				case "Rectangle":
					return this.Rectangle;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
		#region PersonDisplayName
		public TextXmpPropertyValue PersonDisplayName { get; set; }
		#endregion
		#region PersonEmailDigest
		public TextXmpPropertyValue PersonEmailDigest { get; set; }
		#endregion
		#region PersonLiveCID
		public TextXmpPropertyValue PersonLiveCID { get; set; }
		#endregion
		#region Rectangle
		public TextXmpPropertyValue Rectangle { get; set; }
		#endregion
		#region SetFieldCore
		protected override void SetFieldCore(string name, XmpPropertyValue value)
		{
			//確認參數
			if (value != null && !(value is TextXmpPropertyValue))
				throw new ArgumentException();

			//設定欄位
			switch (name)
			{
				case "PersonDisplayName":
					this.PersonDisplayName = (value as TextXmpPropertyValue);
					break;
				case "PersonEmailDigest":
					this.PersonEmailDigest = (value as TextXmpPropertyValue);
					break;
				case "PersonLiveCID":
					this.PersonLiveCID = (value as TextXmpPropertyValue);
					break;
				case "Rectangle":
					this.Rectangle = (value as TextXmpPropertyValue);
					break;
				default:
					throw new ArgumentException();
			}
		}
		#endregion
	}

	public class RegionXmpPropertyValueFactory : StructureXmpPropertyValueFactory<RegionXmpPropertyValue>
	{
		#region 建構子
		public RegionXmpPropertyValueFactory()
			: base(RegionXmpPropertyValue.DefaultSchema.NamespaceURI, new string[] { "PersonDisplayName" })
		{ }
		#endregion
		#region CreateValue
		protected override RegionXmpPropertyValue CreateValue(XmpSchema schema)
		{
			return new RegionXmpPropertyValue(schema);
		}
		#endregion
	}
}
